{extend name="public:layout" /}
{block name="title"}优惠券列表{/block}
{block name="head"}{/block}
{block name="body"}
<div class="wrapper wrapper-content">
    <div class="ibox">
        <div class="ibox-title">
            <ol class="breadcrumb">
                <li><i class="fa fa-hand-o-right"></i> <a href="{:url('index')}"> 优惠券列表</a></li>
                <li class="active">查看券号</li>
            </ol>
        </div>
        <div class="ibox-content">
            <div class="toolbar">
                <div class="pull-right">
                    <form class="form-inline" method="post" id="searchForm">
                        <input type="hidden" id="type" name="type" value="{$query.type}" />
                        <div class="form-group">
                            <div class="input-group">
                                <input class="form-control" name="card_key" type="text" value="{$query.card_key}" placeholder="请输入优惠券号">
                            </div>
                        </div>
                        <button type="submit" class="btn btn-info">
                            <i class="fa fa-search"></i> 搜索
                        </button>
                        <a class="btn btn-white" href="{:url('viewCardKey')}">
                            <i class="fa fa-trash"></i> 清空
                        </a>
                    </form>
                </div>
                <div class="clearfix"></div>
            </div>
            <ul class="nav nav-tabs" id="tab_search">
                <li data-type="unused" {eq name="query.type" value="unused"}class="active"{/eq}><a href="javascript:;">可使用</a></li>
                <li data-type="used" {eq name="query.type" value="used"}class="active"{/eq}><a href="javascript:;">已使用</a></li>
                <li data-type="expire" {eq name="query.type" value="expire"}class="active"{/eq}><a href="javascript:;">已过期</a></li>
            </ul>
            <script>
                $(function () {
                    $('#tab_search li').click(function () {
                        var type=$(this).data('type');
                        $('#type').val(type);
                        $('#searchForm').submit();
                    });
                })
            </script>
            <table class="table" id="grid">
                <tr>
                    <th>#</th>
                    <th>优惠券码</th>
                    <th>用户</th>
                    <th>领取时间</th>
                    <th>订单</th>
                    <th>是否使用</th>
                    <th>使用日期</th>
                    <th>抵扣金额</th>
                    <th>操作</th>
                </tr>
                {volist name="list" id="vo"}
                    <tr>
                        <td>{$vo.item_id}</td>
                        <td>{$vo.card_key}</td>
                        <td>
                            {empty name="vo.member_uid"}
                                N
                            {else/}
                                {:get_field_value('user','username',['uid'=>$vo['member_uid']])}
                            {/empty}
                        </td>
                        <td>
                            {empty name="vo.receive_time"}
                                N
                            {else/}
                                {$vo.receive_time|date="Y-m-d H:i",###}
                            {/empty}
                        </td>
                        <td>
                            {empty name="vo.order_id"}
                                N
                            {else/}
                                {$vo.order_id}
                            {/empty}
                            {$vo.order_money}
                        </td>
                        <td>
                            {empty name="vo.is_use"}
                                N
                            {else/}
                                {$vo.is_use}
                            {/empty}
                        </td>
                        <td>
                            {empty name="vo.use_time"}
                                N
                            {else/}
                                {$vo.use_time|date="Y-m-d H:i",###}
                            {/empty}
                        </td>
                        <td>{$vo.use_card_money}元</td>
                        <td>
                            {neq name="$Request.param.type" value="used"}
                                <a href="javascript:;" onclick="doAction(this);" data-params="item_id={$vo.item_id}"
                                   data-msg="确认操作吗？" data-url="{:url('delItem')}">删除</a>
                            {/neq}
                        </td>
                    </tr>
                {/volist}
            </table>
            <div class="page-bar">{$list->render()}</div>
            <div class="clearfix"></div>
        </div>
    </div>
</div>
{/block}
{block name="script"}{/block}